package com.plugin.activity.pluginproject

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.plugin.activity.stander.ActivityInterface

open class BaseActivity : Activity(), ActivityInterface {

    var appActivity: Activity? = null // 宿主的环境
    override fun insertAppContext(appActivity: Activity?) {
        this.appActivity = appActivity
    }

    @SuppressLint("MissingSuperCall")
    override fun onCreate(savedInstanceState: Bundle?) {

    }

    @SuppressLint("MissingSuperCall")
    override fun onStart() {

    }

    @SuppressLint("MissingSuperCall")
    override fun onResume() {

    }

    override fun setContentView(layoutResID: Int) {
        appActivity?.setContentView(layoutResID)
    }

    override fun <T : View?> findViewById(id: Int): T {
        return appActivity?.findViewById(id)!!
    }

    override fun getIntent(): Intent {
        return appActivity?.intent!!
    }

    override fun getClassLoader(): ClassLoader {
        return appActivity?.classLoader!!
    }
    @SuppressLint("MissingSuperCall")
    override fun onDestroy() {

    }

    override fun startActivity(intent: Intent) {
        val intentNew = Intent()
        intentNew.putExtra("className", intent.component!!.className)
        appActivity?.startActivity(intentNew)
    }
}